{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "122aebfd",
   "metadata": {},
   "source": [
    "* 时间：2022-09-26/week06\n",
    "* 课程：\n",
    "* 学习记录人：yy"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "726dfb6c",
   "metadata": {},
   "source": [
    "# 本周知识点\n",
    "\n",
    ">1. 随机函数\n",
    ">2. 时间函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1c19042a",
   "metadata": {},
   "source": [
    "## 1. 随机函数\n",
    "\n",
    ">1. random.random():生成随机数，0-1之间随机数\n",
    ">2. random.randint():生成随机数\n",
    ">3. random.choices():随机抽样"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "568ce04b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "54818624",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>方法</th>\n",
       "      <th>描述</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>seed()</td>\n",
       "      <td>初始化随机数生成器。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>getstate()</td>\n",
       "      <td>返回随机数生成器的当前内部状态。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>setstate()</td>\n",
       "      <td>恢复随机数生成器的内部状态。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>getrandbits()</td>\n",
       "      <td>返回表示随机位的数字。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>randrange()</td>\n",
       "      <td>返回给定范围之间的随机数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>randint()</td>\n",
       "      <td>返回给定范围之间的随机数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>choice()</td>\n",
       "      <td>返回给定序列中的随机元素。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>choices()</td>\n",
       "      <td>返回一个列表，其中包含给定序列中的随机选择。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>shuffle()</td>\n",
       "      <td>接受一个序列，并以随机顺序返回此序列。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>sample()</td>\n",
       "      <td>返回序列的给定样本。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>random()</td>\n",
       "      <td>返回 0 与 1 之间的浮点数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>uniform()</td>\n",
       "      <td>返回两个给定参数之间的随机浮点数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>triangular()</td>\n",
       "      <td>返回两个给定参数之间的随机浮点数，您还可以设置模式参数以指定其他两个参数之间的中点。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>betavariate()</td>\n",
       "      <td>基于 Beta 分布（用于统计学）返回 0 到 1 之间的随机浮点数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>expovariate()</td>\n",
       "      <td>基于指数分布（用于统计学），返回 0 到 1 之间的随机浮点数，如果参数为负，则返回 0 到...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>gammavariate()</td>\n",
       "      <td>基于 Gamma 分布（用于统计学）返回 0 到 1 之间的随机浮点数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>gauss()</td>\n",
       "      <td>基于高斯分布（用于概率论）返回 0 到 1 之间的随机浮点数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>lognormvariate()</td>\n",
       "      <td>基于对数正态分布（用于概率论）返回 0 到 1 之间的随机浮点数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>normalvariate()</td>\n",
       "      <td>基于正态分布（用于概率论）返回 0 到 1 之间的随机浮点数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>vonmisesvariate()</td>\n",
       "      <td>基于 von Mises 分布（用于定向统计学）返回 0 到 1 之间的随机浮点数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>paretovariate()</td>\n",
       "      <td>基于 Pareto 分布（用于概率论）返回 0 到 1 之间的随机浮点数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>weibullvariate()</td>\n",
       "      <td>基于 Weibull 分布（用于统计学）返回 0 到 1 之间的随机浮点数。</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   方法                                                 描述\n",
       "0              seed()                                         初始化随机数生成器。\n",
       "1          getstate()                                   返回随机数生成器的当前内部状态。\n",
       "2          setstate()                                     恢复随机数生成器的内部状态。\n",
       "3       getrandbits()                                        返回表示随机位的数字。\n",
       "4         randrange()                                      返回给定范围之间的随机数。\n",
       "5           randint()                                      返回给定范围之间的随机数。\n",
       "6            choice()                                      返回给定序列中的随机元素。\n",
       "7           choices()                             返回一个列表，其中包含给定序列中的随机选择。\n",
       "8           shuffle()                                接受一个序列，并以随机顺序返回此序列。\n",
       "9            sample()                                         返回序列的给定样本。\n",
       "10           random()                                   返回 0 与 1 之间的浮点数。\n",
       "11          uniform()                                  返回两个给定参数之间的随机浮点数。\n",
       "12       triangular()         返回两个给定参数之间的随机浮点数，您还可以设置模式参数以指定其他两个参数之间的中点。\n",
       "13      betavariate()                基于 Beta 分布（用于统计学）返回 0 到 1 之间的随机浮点数。\n",
       "14      expovariate()  基于指数分布（用于统计学），返回 0 到 1 之间的随机浮点数，如果参数为负，则返回 0 到...\n",
       "15     gammavariate()               基于 Gamma 分布（用于统计学）返回 0 到 1 之间的随机浮点数。\n",
       "16            gauss()                    基于高斯分布（用于概率论）返回 0 到 1 之间的随机浮点数。\n",
       "17   lognormvariate()                  基于对数正态分布（用于概率论）返回 0 到 1 之间的随机浮点数。\n",
       "18    normalvariate()                    基于正态分布（用于概率论）返回 0 到 1 之间的随机浮点数。\n",
       "19  vonmisesvariate()         基于 von Mises 分布（用于定向统计学）返回 0 到 1 之间的随机浮点数。\n",
       "20    paretovariate()              基于 Pareto 分布（用于概率论）返回 0 到 1 之间的随机浮点数。\n",
       "21   weibullvariate()             基于 Weibull 分布（用于统计学）返回 0 到 1 之间的随机浮点数。"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"https://www.w3school.com.cn/python/python_module_random.asp\")[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5bf95ec5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "7e4c556e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function random:\n",
      "\n",
      "random() method of random.Random instance\n",
      "    random() -> x in the interval [0, 1).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.random) #0-1 float 小数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d857159a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5674427880583406"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "b6250a7b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method randint in module random:\n",
      "\n",
      "randint(a, b) method of random.Random instance\n",
      "    Return random integer in range [a, b], including both end points.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.randint) #整数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "c7eb5d25",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(1,8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "335c7366",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n",
      "1\n",
      "6\n",
      "2\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "# randint小实践：大话骰\n",
    "for i in range(5):\n",
    "    print(random.randint(1,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "bb0c2e42",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Lihua'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# random.choice(),在数据组（列表）随机选择一个值\n",
    "random.choice([\"Alex\",\"Xiaohong\",\"Lihua\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "b52a8c91",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "15\n",
      "15\n",
      "71\n",
      "17\n",
      "27\n",
      "69\n"
     ]
    }
   ],
   "source": [
    "# 通过随机值，大概去判断一下彩票的中间概率\n",
    "# [12,34,65,10,22,12]\n",
    "for i in range(6):\n",
    "    print(random.randint(0,99))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3275d2cb",
   "metadata": {},
   "source": [
    "## 2.时间函数  time（）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a58379ea",
   "metadata": {},
   "source": [
    "* 时间延迟函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "f4c0f715",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "b3951289",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=26, tm_hour=10, tm_min=27, tm_sec=45, tm_wday=0, tm_yday=269, tm_isdst=0)"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "58e4ef60",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sleep in module time:\n",
      "\n",
      "sleep(...)\n",
      "    sleep(seconds)\n",
      "    \n",
      "    Delay execution for a given number of seconds.  The argument may be\n",
      "    a floating point number for subsecond precision.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time.sleep)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "b5d43cac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "time.sleep(2)\n",
    "print(\"hello world\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d51b4e0",
   "metadata": {},
   "source": [
    "* 实践：浏览抓取网页数据，模拟人的行为，让机器慢下来，每执行一次休息3秒钟\n",
    "* 进阶：随机产生一个数（3，50），让程序停留随机的秒数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "4e7fb5ad",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "数据获取...\n",
      "页面停留 5 秒\n",
      "继续下一页...\n",
      "数据获取...\n",
      "页面停留 5 秒\n",
      "继续下一页...\n",
      "数据获取...\n",
      "页面停留 19 秒\n",
      "继续下一页...\n",
      "数据获取...\n",
      "页面停留 9 秒\n",
      "继续下一页...\n",
      "数据获取...\n",
      "页面停留 20 秒\n",
      "继续下一页...\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(\"数据获取...\")\n",
    "    wait_time = random.randint(3,20)\n",
    "    print(\"页面停留\",wait_time,\"秒\")\n",
    "    time.sleep(wait_time)\n",
    "    print(\"继续下一页...\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "eeda3686",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "当前是偶数秒\n",
      "等待时间(随机): 3\n",
      "--------\n",
      "当前是奇数秒\n",
      "等待时间(随机): 1\n",
      "--------\n",
      "当前是偶数秒\n",
      "等待时间(随机): 1\n",
      "--------\n",
      "当前是奇数秒\n",
      "等待时间(随机): 5\n",
      "--------\n",
      "当前是偶数秒\n",
      "等待时间(随机): 1\n",
      "--------\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "import time,random\n",
    "\n",
    "odds = [ 1,  3,  5,  7,  9, 11, 13, 15, 17, 19,\n",
    "       21, 23, 25, 27, 29, 31, 33, 35, 37, 39,\n",
    "       41, 43, 45, 47, 49, 51, 53, 55, 57, 59 ]\n",
    "\n",
    "for i in range(5):\n",
    "\n",
    "    right_this_seconds = datetime.datetime.today().second\n",
    "    if right_this_seconds in odds:\n",
    "        print(\"当前是奇数秒\")\n",
    "    else:\n",
    "        print(\"当前是偶数秒\")\n",
    "    wait_time = random.randint(1,5)\n",
    "    print(\"等待时间(随机):\",wait_time)\n",
    "    time.sleep(wait_time)\n",
    "    print(\"--------\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "fbdcf1c2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles of beer on the wall.\n",
      "99 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "98 bottles of beer on the wall.\n",
      "98 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "97 bottles of beer on the wall.\n",
      "97 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "96 bottles of beer on the wall.\n",
      "96 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "95 bottles of beer on the wall.\n",
      "95 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "94 bottles of beer on the wall.\n",
      "94 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "93 bottles of beer on the wall.\n",
      "93 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "92 bottles of beer on the wall.\n",
      "92 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "91 bottles of beer on the wall.\n",
      "91 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "90 bottles of beer on the wall.\n",
      "90 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "89 bottles of beer on the wall.\n",
      "89 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "88 bottles of beer on the wall.\n",
      "88 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "87 bottles of beer on the wall.\n",
      "87 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "86 bottles of beer on the wall.\n",
      "86 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "85 bottles of beer on the wall.\n",
      "85 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "84 bottles of beer on the wall.\n",
      "84 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "83 bottles of beer on the wall.\n",
      "83 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "82 bottles of beer on the wall.\n",
      "82 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "81 bottles of beer on the wall.\n",
      "81 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "80 bottles of beer on the wall.\n",
      "80 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "79 bottles of beer on the wall.\n",
      "79 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "78 bottles of beer on the wall.\n",
      "78 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "77 bottles of beer on the wall.\n",
      "77 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "76 bottles of beer on the wall.\n",
      "76 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "75 bottles of beer on the wall.\n",
      "75 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "74 bottles of beer on the wall.\n",
      "74 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "73 bottles of beer on the wall.\n",
      "73 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "72 bottles of beer on the wall.\n",
      "72 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "71 bottles of beer on the wall.\n",
      "71 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "70 bottles of beer on the wall.\n",
      "70 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "69 bottles of beer on the wall.\n",
      "69 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "68 bottles of beer on the wall.\n",
      "68 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "67 bottles of beer on the wall.\n",
      "67 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "66 bottles of beer on the wall.\n",
      "66 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "65 bottles of beer on the wall.\n",
      "65 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "64 bottles of beer on the wall.\n",
      "64 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "63 bottles of beer on the wall.\n",
      "63 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "62 bottles of beer on the wall.\n",
      "62 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "61 bottles of beer on the wall.\n",
      "61 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "60 bottles of beer on the wall.\n",
      "60 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "59 bottles of beer on the wall.\n",
      "59 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "58 bottles of beer on the wall.\n",
      "58 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "57 bottles of beer on the wall.\n",
      "57 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "56 bottles of beer on the wall.\n",
      "56 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "55 bottles of beer on the wall.\n",
      "55 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "54 bottles of beer on the wall.\n",
      "54 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "53 bottles of beer on the wall.\n",
      "53 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "52 bottles of beer on the wall.\n",
      "52 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "51 bottles of beer on the wall.\n",
      "51 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "50 bottles of beer on the wall.\n",
      "50 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "49 bottles of beer on the wall.\n",
      "49 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "48 bottles of beer on the wall.\n",
      "48 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "47 bottles of beer on the wall.\n",
      "47 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "46 bottles of beer on the wall.\n",
      "46 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "45 bottles of beer on the wall.\n",
      "45 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "44 bottles of beer on the wall.\n",
      "44 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "43 bottles of beer on the wall.\n",
      "43 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "42 bottles of beer on the wall.\n",
      "42 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "41 bottles of beer on the wall.\n",
      "41 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "40 bottles of beer on the wall.\n",
      "40 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "39 bottles of beer on the wall.\n",
      "39 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "38 bottles of beer on the wall.\n",
      "38 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "37 bottles of beer on the wall.\n",
      "37 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "36 bottles of beer on the wall.\n",
      "36 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "35 bottles of beer on the wall.\n",
      "35 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "34 bottles of beer on the wall.\n",
      "34 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "33 bottles of beer on the wall.\n",
      "33 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "32 bottles of beer on the wall.\n",
      "32 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "31 bottles of beer on the wall.\n",
      "31 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "30 bottles of beer on the wall.\n",
      "30 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "29 bottles of beer on the wall.\n",
      "29 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "28 bottles of beer on the wall.\n",
      "28 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "27 bottles of beer on the wall.\n",
      "27 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "26 bottles of beer on the wall.\n",
      "26 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "25 bottles of beer on the wall.\n",
      "25 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "24 bottles of beer on the wall.\n",
      "24 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "23 bottles of beer on the wall.\n",
      "23 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "22 bottles of beer on the wall.\n",
      "22 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "21 bottles of beer on the wall.\n",
      "21 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "20 bottles of beer on the wall.\n",
      "20 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "19 bottles of beer on the wall.\n",
      "19 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "18 bottles of beer on the wall.\n",
      "18 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "17 bottles of beer on the wall.\n",
      "17 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "16 bottles of beer on the wall.\n",
      "16 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "15 bottles of beer on the wall.\n",
      "15 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "14 bottles of beer on the wall.\n",
      "14 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "13 bottles of beer on the wall.\n",
      "13 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "12 bottles of beer on the wall.\n",
      "12 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "11 bottles of beer on the wall.\n",
      "11 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "10 bottles of beer on the wall.\n",
      "10 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "9 bottles of beer on the wall.\n",
      "9 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "8 bottles of beer on the wall.\n",
      "8 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "7 bottles of beer on the wall.\n",
      "7 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "6 bottles of beer on the wall.\n",
      "6 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "5 bottles of beer on the wall.\n",
      "5 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "4 bottles of beer on the wall.\n",
      "4 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "3 bottles of beer on the wall.\n",
      "3 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "2 bottles of beer on the wall.\n",
      "2 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "----------\n",
      "1 bottles of beer on the wall.\n",
      "1 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "No more bottles of beer on the wall.\n",
      "----------\n"
     ]
    }
   ],
   "source": [
    "beer_name = \"bottles\"\n",
    "\n",
    "for beer_num in range(99,0,-1):\n",
    "    \n",
    "    print(beer_num,beer_name,\"of beer on the wall.\")\n",
    "    print(beer_num,beer_name,\"of beer.\")\n",
    "    print(\"Take one down.\")\n",
    "    print(\"Pass it around.\")\n",
    "    \n",
    "    if beer_num == 1:\n",
    "            print(\"No more bottles of beer on the wall.\")\n",
    "            \n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        \n",
    "        if new_num == 1:  \n",
    "            beer_name = \"bottle\" \n",
    "        print(new_num,beer_name,\"of beer on the wall.\")\n",
    "        \n",
    "    print(\"----------\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cbb12a38",
   "metadata": {},
   "source": [
    "## 3.有序的数据结构()\n",
    ">1. 数值\n",
    ">>1. [数值的运算](https://docs.python.org/3.8/tutorial/introduction.html#numbers)\n",
    "\n",
    "\n",
    ">2. 字符串\n",
    "\n",
    ">3. 列表，元组，字典，*集合（其中考核）P144前"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "405acd37",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "0b347f9d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Operation</th>\n",
       "      <th>Result</th>\n",
       "      <th>Notes</th>\n",
       "      <th>Full documentation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>x + y</td>\n",
       "      <td>sum of x and y</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>x - y</td>\n",
       "      <td>difference of x and y</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>x * y</td>\n",
       "      <td>product of x and y</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>x / y</td>\n",
       "      <td>quotient of x and y</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>x // y</td>\n",
       "      <td>floored quotient of x and y</td>\n",
       "      <td>(1)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>x % y</td>\n",
       "      <td>remainder of x / y</td>\n",
       "      <td>(2)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-x</td>\n",
       "      <td>x negated</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>+x</td>\n",
       "      <td>x unchanged</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>abs(x)</td>\n",
       "      <td>absolute value or magnitude of x</td>\n",
       "      <td>NaN</td>\n",
       "      <td>abs()</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>int(x)</td>\n",
       "      <td>x converted to integer</td>\n",
       "      <td>(3)(6)</td>\n",
       "      <td>int()</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>float(x)</td>\n",
       "      <td>x converted to floating point</td>\n",
       "      <td>(4)(6)</td>\n",
       "      <td>float()</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>complex(re, im)</td>\n",
       "      <td>a complex number with real part re, imaginary ...</td>\n",
       "      <td>(6)</td>\n",
       "      <td>complex()</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>c.conjugate()</td>\n",
       "      <td>conjugate of the complex number c</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>divmod(x, y)</td>\n",
       "      <td>the pair (x // y, x % y)</td>\n",
       "      <td>(2)</td>\n",
       "      <td>divmod()</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>pow(x, y)</td>\n",
       "      <td>x to the power y</td>\n",
       "      <td>(5)</td>\n",
       "      <td>pow()</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>x ** y</td>\n",
       "      <td>x to the power y</td>\n",
       "      <td>(5)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Operation                                             Result  \\\n",
       "0             x + y                                     sum of x and y   \n",
       "1             x - y                              difference of x and y   \n",
       "2             x * y                                 product of x and y   \n",
       "3             x / y                                quotient of x and y   \n",
       "4            x // y                        floored quotient of x and y   \n",
       "5             x % y                                 remainder of x / y   \n",
       "6                -x                                          x negated   \n",
       "7                +x                                        x unchanged   \n",
       "8            abs(x)                   absolute value or magnitude of x   \n",
       "9            int(x)                             x converted to integer   \n",
       "10         float(x)                      x converted to floating point   \n",
       "11  complex(re, im)  a complex number with real part re, imaginary ...   \n",
       "12    c.conjugate()                  conjugate of the complex number c   \n",
       "13     divmod(x, y)                           the pair (x // y, x % y)   \n",
       "14        pow(x, y)                                   x to the power y   \n",
       "15           x ** y                                   x to the power y   \n",
       "\n",
       "     Notes Full documentation  \n",
       "0      NaN                NaN  \n",
       "1      NaN                NaN  \n",
       "2      NaN                NaN  \n",
       "3      NaN                NaN  \n",
       "4      (1)                NaN  \n",
       "5      (2)                NaN  \n",
       "6      NaN                NaN  \n",
       "7      NaN                NaN  \n",
       "8      NaN              abs()  \n",
       "9   (3)(6)              int()  \n",
       "10  (4)(6)            float()  \n",
       "11     (6)          complex()  \n",
       "12     NaN                NaN  \n",
       "13     (2)           divmod()  \n",
       "14     (5)              pow()  \n",
       "15     (5)                NaN  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"https://docs.python.org/3.8/library/stdtypes.html#numeric-types-int-float-complex\")[2]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3ec80c71",
   "metadata": {},
   "source": [
    "### 3.1 Pyton数字"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "869b19a3",
   "metadata": {},
   "source": [
    " * int\n",
    " * Int 或整数是完整的数字，正数或负数，没有小数，长度不限。\n",
    " * x = 10\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6b5d4b69",
   "metadata": {},
   "source": [
    "* float\n",
    "* Float 浮动或“浮点数”是包含小数的正数或负数。\n",
    "* 浮点数也可以是带有“e”的科学数字，表示 10 的幂。\n",
    "* y = 6.3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6df33680",
   "metadata": {},
   "source": [
    "* complex (复数）\n",
    "* z = 2j\n",
    "* 复数用 \"j\" 作为虚部编写"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "8e6b7d32",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10.0\n",
      "6\n",
      "(10+0j)\n"
     ]
    }
   ],
   "source": [
    "x = float(10)\n",
    "\n",
    "y = int(6.3)\n",
    "\n",
    "z = complex(x)\n",
    "\n",
    "print(x)\n",
    "print(y)\n",
    "print(z)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19a15e8d",
   "metadata": {},
   "source": [
    "### 3.2数值的一般用法（methon）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "da3485c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x04\\x00'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(1024).to_bytes(10,byteorder='big')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "94243820",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(2.0).is_integer()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e2d327d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2.0.is_integer()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce06ff04",
   "metadata": {},
   "source": [
    "### 4.字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c26308e0",
   "metadata": {},
   "source": [
    "### 课后作业"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c5d13aeb",
   "metadata": {},
   "source": [
    "> 1.什么是字符串？  \n",
    "> 2.字符串一般有什么形式？  \n",
    "> 3.字符串的运算有哪些？譬如：+ 是什么意思，取值，切片，索引的概念是什么？   \n",
    "> 4.字符串的一般方法？譬如：count()，in  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "08b909e0",
   "metadata": {},
   "source": [
    "* 1.字符串就是放在引号里面的一系列字符,就是标点符号和字母文字组成的那些单词、句子。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bca08a69",
   "metadata": {},
   "source": [
    "* 2.字符串的一般有形式：单引号、双引号、三个双引号、三个单引号。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "35a7b6db",
   "metadata": {},
   "source": [
    "* 3.字符串的运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7753ffbf",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "b7650cd2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>运算符</th>\n",
       "      <th>名称</th>\n",
       "      <th>实例</th>\n",
       "      <th>试一试</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>+</td>\n",
       "      <td>加</td>\n",
       "      <td>x + y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-</td>\n",
       "      <td>减</td>\n",
       "      <td>x - y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>*</td>\n",
       "      <td>乘</td>\n",
       "      <td>x * y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>/</td>\n",
       "      <td>除</td>\n",
       "      <td>x / y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>%</td>\n",
       "      <td>取模</td>\n",
       "      <td>x % y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>**</td>\n",
       "      <td>幂</td>\n",
       "      <td>x ** y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>//</td>\n",
       "      <td>地板除（取整除）</td>\n",
       "      <td>x // y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  运算符        名称      实例  试一试\n",
       "0   +         加   x + y  试一试\n",
       "1   -         减   x - y  试一试\n",
       "2   *         乘   x * y  试一试\n",
       "3   /         除   x / y  试一试\n",
       "4   %        取模   x % y  试一试\n",
       "5  **         幂  x ** y  试一试\n",
       "6  //  地板除（取整除）  x // y  试一试"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"https://www.w3school.com.cn/python/python_operators.asp\")[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "4732b714",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>运算符</th>\n",
       "      <th>实例</th>\n",
       "      <th>等同于</th>\n",
       "      <th>试一试</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>=</td>\n",
       "      <td>x = 5</td>\n",
       "      <td>x = 5</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>+=</td>\n",
       "      <td>x += 3</td>\n",
       "      <td>x = x + 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-=</td>\n",
       "      <td>x -= 3</td>\n",
       "      <td>x = x - 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>*=</td>\n",
       "      <td>x *= 3</td>\n",
       "      <td>x = x * 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>/=</td>\n",
       "      <td>x /= 3</td>\n",
       "      <td>x = x / 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>%=</td>\n",
       "      <td>x %= 3</td>\n",
       "      <td>x = x % 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>//=</td>\n",
       "      <td>x //= 3</td>\n",
       "      <td>x = x // 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>**=</td>\n",
       "      <td>x **= 3</td>\n",
       "      <td>x = x ** 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>&amp;=</td>\n",
       "      <td>x &amp;= 3</td>\n",
       "      <td>x = x &amp; 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>|=</td>\n",
       "      <td>x |= 3</td>\n",
       "      <td>x = x | 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>^=</td>\n",
       "      <td>x ^= 3</td>\n",
       "      <td>x = x ^ 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>&gt;&gt;=</td>\n",
       "      <td>x &gt;&gt;= 3</td>\n",
       "      <td>x = x &gt;&gt; 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>&lt;&lt;=</td>\n",
       "      <td>x &lt;&lt;= 3</td>\n",
       "      <td>x = x &lt;&lt; 3</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    运算符       实例         等同于  试一试\n",
       "0     =    x = 5       x = 5  试一试\n",
       "1    +=   x += 3   x = x + 3  试一试\n",
       "2    -=   x -= 3   x = x - 3  试一试\n",
       "3    *=   x *= 3   x = x * 3  试一试\n",
       "4    /=   x /= 3   x = x / 3  试一试\n",
       "5    %=   x %= 3   x = x % 3  试一试\n",
       "6   //=  x //= 3  x = x // 3  试一试\n",
       "7   **=  x **= 3  x = x ** 3  试一试\n",
       "8    &=   x &= 3   x = x & 3  试一试\n",
       "9    |=   x |= 3   x = x | 3  试一试\n",
       "10   ^=   x ^= 3   x = x ^ 3  试一试\n",
       "11  >>=  x >>= 3  x = x >> 3  试一试\n",
       "12  <<=  x <<= 3  x = x << 3  试一试"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"https://www.w3school.com.cn/python/python_operators.asp\")[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "213d0d78",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>运算符</th>\n",
       "      <th>名称</th>\n",
       "      <th>实例</th>\n",
       "      <th>试一试</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>==</td>\n",
       "      <td>等于</td>\n",
       "      <td>x == y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>!=</td>\n",
       "      <td>不等于</td>\n",
       "      <td>x != y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>&gt;</td>\n",
       "      <td>大于</td>\n",
       "      <td>x &gt; y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>&lt;</td>\n",
       "      <td>小于</td>\n",
       "      <td>x &lt; y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>&gt;=</td>\n",
       "      <td>大于或等于</td>\n",
       "      <td>x &gt;= y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>&lt;=</td>\n",
       "      <td>小于或等于</td>\n",
       "      <td>x &lt;= y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  运算符     名称      实例  试一试\n",
       "0  ==     等于  x == y  试一试\n",
       "1  !=    不等于  x != y  试一试\n",
       "2   >     大于   x > y  试一试\n",
       "3   <     小于   x < y  试一试\n",
       "4  >=  大于或等于  x >= y  试一试\n",
       "5  <=  小于或等于  x <= y  试一试"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"https://www.w3school.com.cn/python/python_operators.asp\")[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "0191ea39",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>运算符</th>\n",
       "      <th>描述</th>\n",
       "      <th>实例</th>\n",
       "      <th>试一试</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>and</td>\n",
       "      <td>如果两个语句都为真，则返回 True。</td>\n",
       "      <td>x &gt; 3 and x &lt; 10</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>or</td>\n",
       "      <td>如果其中一个语句为真，则返回 True。</td>\n",
       "      <td>x &gt; 3 or x &lt; 4</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>not</td>\n",
       "      <td>反转结果，如果结果为 true，则返回 False</td>\n",
       "      <td>not(x &gt; 3 and x &lt; 10)</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   运算符                         描述                     实例  试一试\n",
       "0  and        如果两个语句都为真，则返回 True。       x > 3 and x < 10  试一试\n",
       "1   or       如果其中一个语句为真，则返回 True。         x > 3 or x < 4  试一试\n",
       "2  not  反转结果，如果结果为 true，则返回 False  not(x > 3 and x < 10)  试一试"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"https://www.w3school.com.cn/python/python_operators.asp\")[3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "ce465796",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>运算符</th>\n",
       "      <th>描述</th>\n",
       "      <th>实例</th>\n",
       "      <th>试一试</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>is</td>\n",
       "      <td>如果两个变量是同一个对象，则返回 true。</td>\n",
       "      <td>x is y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>is not</td>\n",
       "      <td>如果两个变量不是同一个对象，则返回 true。</td>\n",
       "      <td>x is not y</td>\n",
       "      <td>试一试</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      运算符                       描述          实例  试一试\n",
       "0      is   如果两个变量是同一个对象，则返回 true。      x is y  试一试\n",
       "1  is not  如果两个变量不是同一个对象，则返回 true。  x is not y  试一试"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"https://www.w3school.com.cn/python/python_operators.asp\")[4]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8c19cff0",
   "metadata": {},
   "source": [
    "* 4.字符串的一般方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ae6fcac8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>方法</th>\n",
       "      <th>描述</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>capitalize()</td>\n",
       "      <td>把首字符转换为大写。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>casefold()</td>\n",
       "      <td>把字符串转换为小写。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>center()</td>\n",
       "      <td>返回居中的字符串。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>count()</td>\n",
       "      <td>返回指定值在字符串中出现的次数。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>encode()</td>\n",
       "      <td>返回字符串的编码版本。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>endswith()</td>\n",
       "      <td>如果字符串以指定值结尾，则返回 true。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>expandtabs()</td>\n",
       "      <td>设置字符串的 tab 尺寸。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>find()</td>\n",
       "      <td>在字符串中搜索指定的值并返回它被找到的位置。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>format()</td>\n",
       "      <td>格式化字符串中的指定值。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>format_map()</td>\n",
       "      <td>格式化字符串中的指定值。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>index()</td>\n",
       "      <td>在字符串中搜索指定的值并返回它被找到的位置。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>isalnum()</td>\n",
       "      <td>如果字符串中的所有字符都是字母数字，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>isalpha()</td>\n",
       "      <td>如果字符串中的所有字符都在字母表中，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>isdecimal()</td>\n",
       "      <td>如果字符串中的所有字符都是小数，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>isdigit()</td>\n",
       "      <td>如果字符串中的所有字符都是数字，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>isidentifier()</td>\n",
       "      <td>如果字符串是标识符，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>islower()</td>\n",
       "      <td>如果字符串中的所有字符都是小写，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>isnumeric()</td>\n",
       "      <td>如果字符串中的所有字符都是数，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>isprintable()</td>\n",
       "      <td>如果字符串中的所有字符都是可打印的，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>isspace()</td>\n",
       "      <td>如果字符串中的所有字符都是空白字符，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>istitle()</td>\n",
       "      <td>如果字符串遵循标题规则，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>isupper()</td>\n",
       "      <td>如果字符串中的所有字符都是大写，则返回 True。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>join()</td>\n",
       "      <td>把可迭代对象的元素连接到字符串的末尾。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>ljust()</td>\n",
       "      <td>返回字符串的左对齐版本。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>lower()</td>\n",
       "      <td>把字符串转换为小写。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>lstrip()</td>\n",
       "      <td>返回字符串的左修剪版本。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>maketrans()</td>\n",
       "      <td>返回在转换中使用的转换表。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>partition()</td>\n",
       "      <td>返回元组，其中的字符串被分为三部分。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>replace()</td>\n",
       "      <td>返回字符串，其中指定的值被替换为指定的值。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>rfind()</td>\n",
       "      <td>在字符串中搜索指定的值，并返回它被找到的最后位置。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>rindex()</td>\n",
       "      <td>在字符串中搜索指定的值，并返回它被找到的最后位置。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>rjust()</td>\n",
       "      <td>返回字符串的右对齐版本。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>rpartition()</td>\n",
       "      <td>返回元组，其中字符串分为三部分。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>rsplit()</td>\n",
       "      <td>在指定的分隔符处拆分字符串，并返回列表。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>rstrip()</td>\n",
       "      <td>返回字符串的右边修剪版本。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>split()</td>\n",
       "      <td>在指定的分隔符处拆分字符串，并返回列表。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>splitlines()</td>\n",
       "      <td>在换行符处拆分字符串并返回列表。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>startswith()</td>\n",
       "      <td>如果以指定值开头的字符串，则返回 true。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>strip()</td>\n",
       "      <td>返回字符串的剪裁版本。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>swapcase()</td>\n",
       "      <td>切换大小写，小写成为大写，反之亦然。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>title()</td>\n",
       "      <td>把每个单词的首字符转换为大写。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>translate()</td>\n",
       "      <td>返回被转换的字符串。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>upper()</td>\n",
       "      <td>把字符串转换为大写。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>zfill()</td>\n",
       "      <td>在字符串的开头填充指定数量的 0 值。</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                方法                           描述\n",
       "0     capitalize()                   把首字符转换为大写。\n",
       "1       casefold()                   把字符串转换为小写。\n",
       "2         center()                    返回居中的字符串。\n",
       "3          count()             返回指定值在字符串中出现的次数。\n",
       "4         encode()                  返回字符串的编码版本。\n",
       "5       endswith()        如果字符串以指定值结尾，则返回 true。\n",
       "6     expandtabs()               设置字符串的 tab 尺寸。\n",
       "7           find()       在字符串中搜索指定的值并返回它被找到的位置。\n",
       "8         format()                 格式化字符串中的指定值。\n",
       "9     format_map()                 格式化字符串中的指定值。\n",
       "10         index()       在字符串中搜索指定的值并返回它被找到的位置。\n",
       "11       isalnum()  如果字符串中的所有字符都是字母数字，则返回 True。\n",
       "12       isalpha()  如果字符串中的所有字符都在字母表中，则返回 True。\n",
       "13     isdecimal()    如果字符串中的所有字符都是小数，则返回 True。\n",
       "14       isdigit()    如果字符串中的所有字符都是数字，则返回 True。\n",
       "15  isidentifier()          如果字符串是标识符，则返回 True。\n",
       "16       islower()    如果字符串中的所有字符都是小写，则返回 True。\n",
       "17     isnumeric()     如果字符串中的所有字符都是数，则返回 True。\n",
       "18   isprintable()  如果字符串中的所有字符都是可打印的，则返回 True。\n",
       "19       isspace()  如果字符串中的所有字符都是空白字符，则返回 True。\n",
       "20       istitle()        如果字符串遵循标题规则，则返回 True。\n",
       "21       isupper()    如果字符串中的所有字符都是大写，则返回 True。\n",
       "22          join()          把可迭代对象的元素连接到字符串的末尾。\n",
       "23         ljust()                 返回字符串的左对齐版本。\n",
       "24         lower()                   把字符串转换为小写。\n",
       "25        lstrip()                 返回字符串的左修剪版本。\n",
       "26     maketrans()                返回在转换中使用的转换表。\n",
       "27     partition()           返回元组，其中的字符串被分为三部分。\n",
       "28       replace()        返回字符串，其中指定的值被替换为指定的值。\n",
       "29         rfind()    在字符串中搜索指定的值，并返回它被找到的最后位置。\n",
       "30        rindex()    在字符串中搜索指定的值，并返回它被找到的最后位置。\n",
       "31         rjust()                 返回字符串的右对齐版本。\n",
       "32    rpartition()             返回元组，其中字符串分为三部分。\n",
       "33        rsplit()         在指定的分隔符处拆分字符串，并返回列表。\n",
       "34        rstrip()                返回字符串的右边修剪版本。\n",
       "35         split()         在指定的分隔符处拆分字符串，并返回列表。\n",
       "36    splitlines()             在换行符处拆分字符串并返回列表。\n",
       "37    startswith()       如果以指定值开头的字符串，则返回 true。\n",
       "38         strip()                  返回字符串的剪裁版本。\n",
       "39      swapcase()           切换大小写，小写成为大写，反之亦然。\n",
       "40         title()              把每个单词的首字符转换为大写。\n",
       "41     translate()                   返回被转换的字符串。\n",
       "42         upper()                   把字符串转换为大写。\n",
       "43         zfill()          在字符串的开头填充指定数量的 0 值。"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html(\"https://www.w3school.com.cn/python/python_strings.asp\")[0]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
